package config

import (
	"os"

	"github.com/spf13/viper"
)

type ServiceConfig struct {
	Postgres string // postgres URI
	RabbitMQ string // rabbitMQ URI
}

var Service ServiceConfig

func setupServiceConfig() {
	if err := viper.UnmarshalKey("service", &Service); err != nil {
		panic(err)
	}
	if envPostgres, exists := os.LookupEnv("POSTGRES_DNS"); exists {
		Service.Postgres = envPostgres
	}
	if envRabbitMQ, exists := os.LookupEnv("RABBITMQ_URI"); exists {
		Service.RabbitMQ = envRabbitMQ
	}
}
